import _thread
import time
import urllib.request
import json
import random
import string


def print_time(postData,delay):

    url = "http://www.babei.com/api/v1/login"
    count = 0
    # while count < 20:
    #     count += 1
        # openid = ''.join(random.sample(string.ascii_letters + string.digits, 22))
        # print(openid)
        # exit()
        # postData = {"invite_code":"90683686","openid":openid}
    data = urllib.parse.urlencode(postData).encode(encoding='UTF8')
    response = urllib.request.urlopen(url, data)
        # print(count)
    print (response.read())


try:
    _thread.start_new_thread(print_time, ({"invite_code":"90683686","openid":"fF3gt6mWNuOTYyqn98eSiP"},0))
    _thread.start_new_thread(print_time, ({"invite_code": "90683686", "openid": "fF3gt6mWNuOTYyqn98eSiP"}, 0))
    _thread.start_new_thread(print_time, ({"invite_code": "90683686", "openid": "fF3gt6mWNuOTYyqn98eSiP"}, 0))
    _thread.start_new_thread(print_time, ({"invite_code":"90683686","openid":"fF3gt6mWNuOTYyqn98eSiP"},0))
    _thread.start_new_thread(print_time, ({"invite_code": "90683686", "openid": "fF3gt6mWNuOTYyqn98eSiP"}, 0))
    _thread.start_new_thread(print_time, ({"invite_code": "90683686", "openid": "fF3gt6mWNuOTYyqn98eSiP"}, 0))
    _thread.start_new_thread(print_time, ({"invite_code": "90683686", "openid": "fF3gt6mWNuOTYyqn98eSiP"}, 0))
    _thread.start_new_thread(print_time, ({"invite_code": "90683686", "openid": "fF3gt6mWNuOTYyqn98eSiP"}, 0))
    _thread.start_new_thread(print_time, ({"invite_code": "90683686", "openid": "fF3gt6mWNuOTYyqn98eSiP"}, 0))


except:
    print("Error: 无法启动线程")

while 1:
    pass